/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.breeze.dom;

import org.w3c.dom.Node;
import org.w3c.dom.Text;

/**
 *
 * @author huateng
 */
public class TextTag extends DefaultTag{
    
    public TextTag(Node n){
        super(n);
    }
            
    public TextTag(Node n,Object r){
        super(n,r);
    }
            
    public String display() {
        Text t=(Text)node;
        String str= t.getWholeText();
        StringBuilder sb=new StringBuilder();
        while(str.indexOf("${")>-1){
            int index=str.indexOf("${");
            int end;
            for(end=index+2;end<str.length();end++){
                if(str.charAt(end)=='}')
                    break;
            }
            String name=str.substring(index+2,end);
            String value=(String)getValue(name);
            sb.append(str.substring(0,index)).append(value);
            str=str.substring(end+1);
        }
        sb.append(str);
        return sb.toString();
    }
    
}
